<!DOCTYPE html>
<html >
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>事件对象</title>
    <style>
        div{
            width: 200px;
            height: 200px;
            background-color: red;
        }
        input{
            display: none;
        }
    </style>

</head>
<body>
    <div></div>
    <a href="http://www.baidu.com">百度</a>
    <br>
    <input type="file">
    <button>选择图片</button>
</body>
<script>
    let input = document.querySelector('input');
    let btn = document.querySelector('button');
    btn.addEventListener('click',e =>{
        input.click();
    })



    let a = document.querySelector('a');
    a.addEventListener('click', e =>{
        console.log("a标签被点击了");
        div.click();//主动触发事件
        e.preventDefault();//阻止事件的默认行为，这里阻止页面跳转
    } );

    let div = document.querySelector('div');
    div.addEventListener('click',e => {
        alert('div被点击了');
    })



    
</script>
</html>